|
Perl 6 rules are the regular expression, pattern matching and general-purpose parsing facility of Perl 6, and are a core part of the language. Since Perl's pattern-matching constructs have exceeded the capabilities of formal regular expressions for some time, Perl 6 documentation refers to them exclusively as ''regexes'', distancing the term from the formal definition. Perl 6 provides a superset of Perl 5 features with respect to regexes, folding them into a larger framework called ''rules'', which provide the capabilities of a parsing expression grammar, as well as acting as a closure with respect to their lexical scope.〔(【引用サイトリンク】 title=Synopsis 5: Regexes and Rules )〕 Rules are introduced with the rule keyword, which has a usage quite similar to subroutine definition. Anonymous rules can be introduced with the regex (or rx ) keyword, or simply be used inline as regexps were in Perl 5 via the m (matching) or s (substitution) operators.==History== In ''Apocalypse 5'', a document outlining the preliminary design decisions for Perl 6 pattern matching, Larry Wall enumerated 20 problems with "current regex culture". Among these were that Perl's regexes were "too compact and 'cute'", had "too much reliance on too few metacharacters", "little support for named captures", "little support for grammars", and "poor integration with () 'real' language".〔(【引用サイトリンク】 title=Apocalypse 5: Pattern Matching )〕 Between late 2004 and mid-2005, a compiler for Perl 6 style rules was developed for the Parrot virtual machine called Parrot Grammar Engine (PGE), which was later renamed to the more generic, Parser Grammar Engine. PGE is a combination of runtime and compiler for Perl 6 style grammars that allows any parrot-based compiler to use these tools for parsing, and also to provide rules to their runtimes. Among other Perl 6 features, support for named captures was added to Perl 5.10 in 2007.〔(Perl 5.10 now available - Perl Buzz )〕 In May 2012, the reference implementation of Perl 6, Rakudo, shipped its Rakudo Star monthly snapshot with a working JSON parser built entirely in Perl 6 rules.〔(【引用サイトリンク】 title= Rakudo Star 2012.05 released )〕 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Perl 6 rules」の詳細全文を読む スポンサード リンク
|